<!--
/**************************************************
* @ balanceinforecord.jsp
*
* Copyright   2006 Hitrust Technology Inc.
* Developed by SDC, Hitrust.
* All Rights Reserved.
*
* Modify History:
*  v1.00, 2006/04/17, Jenny Li
*  1) first release
*  v1.01, 2006/06/21, Jenny Li
*  1) 修改取得手动设定参数类型日期区间显示处理方式
/**************************************************
-->
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ include file="../../common.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<title>对帐调整</title>
	<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<LINK href="<%=root%>/css/caigouxitong.css"" type=text/css rel=stylesheet>		
	<SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
	<SCRIPT language="JavaScript" src="<%=root%>/js/calendar.js"></SCRIPT>
	<SCRIPT language="JavaScript" src="<%=root%>/js/hi-check.js"></SCRIPT>
	<%
		GSBalanceParamBean tBalParmBean = (GSBalanceParamBean)request.getAttribute("balanceparm");
		ArrayList shipary=(ArrayList)request.getAttribute("shiporg");
		String tStrDate = (String)request.getAttribute("balancestrdate");
		String tEndDate = (String)request.getAttribute("balanceenddate");
		
	%>
	<script>

		var counter;
		function process(){
			var d = new Date();
			var curYear = d.getYear();
			var curMonth = d.getMonth();
			if(parseInt(document.all.balanceYear.value) > curYear){
				alert("年份不能大于系统年！");
				return false;
			}
			if(parseInt(document.all.balanceMonth.value) > (curMonth + 1)){
				alert("月份不能大于系统月！");
				return false;				
			}
            var category = document.getElementById("Select6");
            if(category.selectedIndex!=0){
                if(document.getElementById("provider_id").value==""){
                    alert("请选择供应商！");
                    return false;
                }
            }
			if(!confirm("是否确定录入?")){
				return false;
			}
			orderbalanceform.action="<%=response.encodeURL(root + "/A180102.do")%>";			
			orderbalanceform.submit();
		}
		
		function changeDate(obj1 , obj2)
		{
			var year1 = obj1.value;
			var year2 = obj1.value;
			var month1;
			var strDate = "<%=tBalParmBean.getGs_balance_start_date()%>";
			var endDate = "<%=tBalParmBean.getGs_balance_end_date()%>";

			<%
				if(tBalParmBean.getGs_balance_date_type().equals(GSBaseConstants.NATURE_BALANCE_DATE)){
			%>
					for(i=1; i<=12; i++){
						if(obj2.value == i){					
				    		endDate = getMaxDay(parseInt(year1),parseInt(obj2.value));
				    		break;
				    	}

					}
				    month1 = obj2.value;
			<%	
				}else if(tBalParmBean.getGs_balance_date_type().equals(GSBaseConstants.MANUAL_BALANCE_DATE)){
			%>
				    //month1= obj2.value;
					if(parseInt(strDate) > parseInt(endDate) || parseInt(strDate) == parseInt(endDate)){
							if (obj2.value == "1")
							{
								month1 = "12";
								year1 = parseInt(year1) - 1;
							}else{						
								month1 = parseInt(obj2.value) - 1;
							}
					}else{
						month1 = obj2.value;
					}
			<%	    
				}
			%>
			 
			var month2 = obj2.value;

			if (parseInt(month1) < 10 ){
				month1 = "0" + month1;			
			}
			if(parseInt(month2) < 10)
			{
				month2 = "0" + month2;
			}			
			if(parseInt(strDate) < 10){
				strDate = "0" + strDate;
			}
			if(parseInt(endDate) < 10){		
				endDate = "0" + endDate;
			}			
			document.all["balanceStrDate"].value = year1 + "/" + month1 + "/" + strDate;
			document.all["balanceEndDate"].value = year2 + "/" + month2 + "/" + endDate;
		}
        function exchangeDept(){
            var category = document.getElementById("Select6");
            var a=category[category.selectedIndex].innerText;
            document.getElementById("Button1").value="生成"+a+"对帐数据";
            if(category.selectedIndex==0){
                document.getElementById("prov").style.display = 'none';
                document.getElementById("dept").style.display = '';
            }else{
                document.getElementById("dept").style.display = 'none';
                document.getElementById("prov").style.display = '';
            }
        }
        function selectCompany()
        {
            var url = "<%=response.encodeURL(root + "/A401103.do")%>";
            var returnv = window.open(url,null," edge: sunken ,center: Yes, help: No, resizable: Yes, status: No,height=580px, scrollbars=yes");
    
        } 
		</script>
	</head>
	<body BGCOLOR="#f2f2f2" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
		<form name="orderbalanceform" method="post">
			<p><br>
			</p>
			<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
				<tr>
					<td height="20">
						<table width="100%" border="0" cellspacing="0" cellpadding="1">
							<tr height="20">
								<td height="30" width="758" class="mtxt_black">本月对帐录入
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td class="bg_line" height="2"></td>
				</tr>
			</table>
			<br>
			<table class="bg_table" id="Table1" cellspacing="1" cellpadding="0" style="PADDING-RIGHT:5px; PADDING-LEFT:5px"
				width="98%" align="center" border="0">
				<TR height="20">
					<TD class="bg_column" align="center">类型</TD>
                    <TD class="bg_row_odd">
                    <select id="Select6" name="payType" onchange="exchangeDept();">
                            <%
                                String payTp = request.getParameter("payType");
                                String[][] tRs = GSBaseManager.getAllPayType();
                                for(int i=0; i < tRs.length; i++){
                                    String[] temp = tRs[i];
                                    if(payTp != null && payTp.equals(temp[0])){
                            %>
                                    <option value="<%=temp[0]%>" selected><%=temp[1]%></option>                                     
                            <%
                                    }else{
                            %>
                                    <option value="<%=temp[0]%>"><%=temp[1]%></option>                          
                            <%      }
                                }
                            %>
                        </select>
                    </TD>
                    <TD class="bg_column" align="center" width="15%">结算单位</TD>
					<TD class="bg_row_odd" width=35%>
						<div id="dept">
                        <select name="orderDeptId">					
						<%
							String tOrderDept = request.getParameter("orderDeptId");
							if(shipary != null && shipary.size() > 0 ){	
									for(int i=0; i<shipary.size(); i++){
									    String[] temp = (String[])shipary.get(i);
										if(tOrderDept != null && tOrderDept.equals(temp[0])){
							%>
											<option value="<%=temp[0]%>" selected><%=temp[1]%></option>
							<%				    
										}else{
							%>
											<option value="<%=temp[0]%>"><%=temp[1]%></option>
							<%			
										}
									}
							    }
						%>
						</select>
                        </div>
                        <div id="prov" style="display:none;">
                        <input type="text" id="provider_name" name="providerName" readonly value="<%=request.getParameter("providerName") == null? "":request.getParameter("providerName")%>">                  
                        <input type="button" class="kuang" value="选择供应商" onClick="selectCompany();">
                        <input type="hidden" class="kuang" name="provider" id="provider_id" value="<%=request.getAttribute("provider") == null? "":request.getAttribute("provider")%>">   
                        </div>
					</TD>
                    </TR>
                    <TR height="20">
					<TD class="bg_column" align="center" width=15%>月份</TD>
					<TD class="bg_row_odd" width=35%>
						
						<SELECT ID="Select2" NAME="balanceYear" onchange="changeDate(this,document.all['Select3']);">
						<%
							int length = 15;
							Calendar cal = Calendar.getInstance();
							int curYear = cal.get(Calendar.YEAR);
							for(int i=0; i<length; i++){
							    if(curYear == (2006 + i)){
						%>
							<OPTION value="<%=2006+i%>" selected><%=2006+i%></OPTION>						
						<%	        
							    }else{
						%>
							<OPTION value="<%=2006+i%>"><%=2006+i%></OPTION>						
						<%		    
							    }
							}
						%>
						</SELECT>年
						<SELECT ID="Select3" NAME="balanceMonth" onchange="changeDate(document.all['Select2'],this);">
						<%
							int curMonth = cal.get(Calendar.MONTH);
							for(int i=1; i<=12; i++){
							    if(curMonth + 1 == i){
						%>
							<OPTION value="<%=i%>" selected><%=i%></OPTION>						
						<%
							    }else{
						%>		
							<OPTION value="<%=i%>"><%=i%></OPTION>												
						<%		    
							    }
							}
						%>
						</SELECT>月
					</TD>
					<TD class="bg_column" align="center">日期</TD>
					<TD class="bg_row_odd" colspan=3>
						<input id="Text27" name='balanceStrDate' readonly onfocus='setday(this)' value='<%=tStrDate%>' size='15'> ~<input id="Text4" name='balanceEndDate' readonly onfocus='setday(this)' value="<%=tEndDate%>" size='15'>
					</TD>
				</tr>
			</table>
		</form>
		<p align="center">
			<INPUT type="button" class="kuang" value="生成对帐数据" ID="Button1" NAME="Button1" onClick="process()">
		</p>
	</body>
    <script type="text/javascript">
exchangeDept();
</script>
</html>
